package com.xinzhi.service.impl;

import com.xinzhi.mapper.JiaFenShenSuMapper;
import com.xinzhi.pojo.dto.JiaFenShenSu;
import com.xinzhi.service.JiaFenShenSuService;
import com.xinzhi.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class JiaFenShenSuServiceImpl implements JiaFenShenSuService {
    @Autowired
    private JiaFenShenSuMapper jiaFenShenSuMapper;

    /**
     * 特殊加分申诉审核查询接口
     * @return
     */
    @Override
    public Result selectJia() {
        return Result.ok(jiaFenShenSuMapper.selectJia());
    }

    /**
     * 特殊加分申诉审核删除接口
     * @param deleted
     * @return
     */
    @Override
    public Result deleteJia(String causeofappeal ,Integer deleted) {
        if (causeofappeal == null && deleted > 1){
            return Result.error("参数错误");
        }
        int i = jiaFenShenSuMapper.deleteJia(causeofappeal, deleted);
        return i>0 ? Result.ok("删除成功") : Result.error("删除失败");
    }

    /**
     * 特殊加分申诉审核根据发布状态查询接口
     * @param publishstatus
     * @return
     */
    @Override
    public Result selectpublish(String publishstatus) {
        if (publishstatus == null){
            return Result.error("参数错误");
        }
        List<JiaFenShenSu> selectpublish = jiaFenShenSuMapper.selectpublish(publishstatus);
        return selectpublish != null ? Result.ok(selectpublish) : Result.error("查询失败");
    }
}
